New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate command usage text #10342
Generate command usage text #10342
Conversation
Review period will end on 2021-01-18 at 21:05:31 UTC. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome! Small feature suggestion that might be useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Maybe someday we'll move each named_args
line to just before or after the description
, but that's a discussion for another time.
I don't think I would be opposed to this. I'd need to see how it looks I guess. Separately, I'm a little confused about the difference between Based on experimentation, it seems that # flag "--foo="
brew cmd --foo=bar # works
brew cmd --foo bar # works
# flag "--foo"
brew cmd --foo=bar # works
brew cmd --foo bar # doesn't work (treats `bar` as normal named argument) It seems that adding |
Oh wait, I'm wrong. Here's an updated explanation: # flag "--foo="
brew cmd --foo=bar # args.foo returns "bar"
brew cmd --foo bar # args.foo returns "bar"
brew cmd --foo # args.foo throws an error: "missing argument: --foo"
# flag "--foo"
brew cmd --foo=bar # args.foo returns "bar"
brew cmd --foo bar # args.foo returns true
brew cmd --foo # args.foo returns true So the question becomes: how should flags in the usage string show up? It seems that In the cases where the argument isn't required, should there be a way to indicate that |
@EricFromCanada I have to say I'm torn about this. I do kind of like them at the end (although I'm not totally sure why). It also adds some consistency with the usage string (in which named args come after options). On the other hand, it's nice to be able to see the |
Just so we're clear, the I'd try to keep complexity down in the usage string, so I'd be fine with just |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work again @Rylan12! 👍🏻 from me once CI is 🟢
The default value isn't actually passed, though, it just needs to be inferred by the code that handles the option.
Okay, let's go with this. I like it: not too cluttered and still easy to understand. |
c58c956
to
98b83e8
Compare
Review period ended. |
Include only global args and list the specific options if there are two or fewer.
161fa14
to
1e4fef8
Compare
I didn't resolve the merge conflict correctly, I believe
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?brew man
locally and committed any changes?This PR uses the new
named_args
method to generate usage strings forbrew help
, docs.brew.sh, and the manpage.For most commands, simply replacing the existing
usage_banner
withdescription
(removing the old usage line from the beginning) is sufficient.There are a few commands that needed special attention (e.g.
tap
orruby
). For these commands, the automatic usage string can be overridden using theusage_string
method.Additionally, aliases (except for
instal
anduninstal
) are now shown in the usage string.CC @dawidd6, @EricFromCanada, and @MikeMcQuaid